package com.onetech.adrewards.free.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.onetech.adrewards.free.apicall.ZuZuCARMApiCall;
import com.onetech.adrewards.free.apicall.ZuZuCARMWebView;
import com.todddavies.components.progressbar.ProgressWheel;
import com.onetech.adrewards.free.R;


public class GetPointsFragment extends BaseFragment {
	private ZuZuCARMWebView mWebView=null;
	private View mLoadingView=null;
	//private View linearLayout=null;
	
	//private String url="http://car.mobadme.jp/spg/spnew/558/2835/index.php?user_id=sampleuser&crypt=4c1dfd440cc7ec41f664646bcc5e06d812a47e4a";
	private static ZuZuCARMApiCall apiCall = null;
	//private	ProgressDialog dialog = null;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {		
		if (mView == null) {
			mView = (RelativeLayout) inflater.inflate(R.layout.get_points_fragment_layout,
					container, false);			
			initView();
			initListener();
		} else {
			((ViewGroup) mView.getParent()).removeView(mView);
		}
		return mView;
	}
	private void initView(){
		mWebView=(ZuZuCARMWebView)mView.findViewById(R.id.myAdRewardWebView);
		mLoadingView=(LinearLayout)mView.findViewById(R.id.waitingLoading);
		mProgress=(ProgressWheel)mView.findViewById(R.id.progressWheel);
		mProgress.setText("");
		mProgress.spin();
		//mWebView.loadUrl(url);
//		mWebView.setWebViewClient(new WebViewClient(){
//			@Override
//			public void onPageStarted(WebView view, String url, Bitmap favicon) {
//				super.onPageStarted(view, url, favicon);
//				mWebView.setVisibility(View.GONE);
//				//mLoadingView.setVisibility(View.VISIBLE);
//			}
//			@Override
//			public void onPageFinished(WebView view, String url) {
//				super.onPageFinished(view, url);
//				//mLoadingView.setVisibility(View.GONE);
//				mWebView.setVisibility(View.VISIBLE);				
//			}
//		});
		
        
		Intent intent = getActivity().getIntent();	
		
		if(apiCall != null) {
			apiCall.cancel(true);
		}
		apiCall = new ZuZuCARMApiCall(intent, getActivity(), this.mWebView, mLoadingView);
		apiCall.execute();
		
	}
	private void initListener(){
		
	}
}
